package main.niit.dao;

import main.niit.pojo.*;
import main.niit.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Get3 {
    public List<top10_sessionData> getall() throws Exception {
        Connection connection=JDBCUtils.getConnection();

        List<top10_sessionData> list3= new ArrayList<>();

        PreparedStatement ps3=null;

        ResultSet resultSet3=null;

        try {
            String sql3 = "SELECT session_id, click_category_id FROM ads_top10_session_datax " ;
            ps3 = connection.prepareStatement(sql3);
            resultSet3 = ps3.executeQuery();
            while (resultSet3.next()) {
                top10_sessionData top10_sessionData= new top10_sessionData();
                top10_sessionData.setSessionId(resultSet3.getString("session_id"));
                top10_sessionData.setClickCategoryId(resultSet3.getLong("click_category_id"));
                list3.add(top10_sessionData);
            }
        }catch (SQLException e){
            e.printStackTrace();
        }finally {
            JDBCUtils.close(ps3,connection);
        }


        return list3;

    }
}
